/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __BLENDER_LOAD_UTIL_H__
#define __BLENDER_LOAD_UTIL_H__

#include "GPrerequisites.h"
#include "blender.h"
#include "bBlenderFile.h"
#include "bMain.h"
#include "blender_Common.h"
#include "OgreMath.h"

namespace GNgine
{
	class BlenderLoadUtil
	{
	public:
		BlenderLoadUtil(bParse::bBlenderFile *file);
		Blender::Material* getMaterial(Blender::Object *object, int index);
		void getLayers(Blender::Mesh *mesh, Blender::MTFace **eightLayerArray, Blender::MCol **oneMCol, int &validLayers);

		// animation / skeleton utils
		int getDeformGroupIndex(Blender::Object *object, const char *group);
		static Ogre::Real evaluateIpoCurve(Blender::IpoCurve *icu, const Ogre::Real& time);

		static bool findApproximateCurve(Ogre::Vector2 &P0,
										 Ogre::Vector2 &P1,
										 Ogre::Vector2 &P2,
										 Ogre::Vector2& P3,
										 Ogre::Real time,
										 Ogre::Real &cval);

		/// defined in scene->r.frs_sec
	public:
		inline static void setBlenderAnimRate(Ogre::Real rate)
		{
			_blenderAnimRate=rate;
		}
		inline static Ogre::Real getBlenderAnimRate()
		{
			return _blenderAnimRate;
		}

	private:
		static Ogre::Real _blenderAnimRate;
		bParse::bBlenderFile *_file;
	};
}

#endif

